package com.learn.exec;

class Bank{
    private Bank(){}

    private static Bank instace = null;

    public  static Bank getInstance(){
 /*       //方式一：效率较差
        synchronized (Bank.class){
            if(instace == null){
                instace = new Bank();
            }
            return instace;
        }
*/
        //方式二：双重检测，效率较高
        if(instace == null){
            synchronized (Bank.class){
                if(instace == null){
                    instace = new Bank();
                }
            }
        }
        return instace;
    }
}

public class BankTest {
}
